<?php
	include("includes/secure.php");
	include("includes/config.php");
	include("includes/class/afp.class.php");
	
	$afp = new Afp(); 	
	
	$msg_info = $msg_alert = $msg_error = false;
	$_SESSION['msg_cool'] = '';
	$show_msg = 0;
			
	if(isset($_POST['addAfp']) && $_POST['addAfp'] == 1){
		$action = $_POST["action"];
		$data->afp_name = trim(mysql_real_escape_string($_POST['afp_name']));
		$data->afp_porc = $_POST['afp_porc'];
		$data->afp_description = trim(mysql_real_escape_string($_POST['afp_description']));
		
	
		if ($data=$afp->addAfp($data) ){
			$msg_info = true;
			$_SESSION["msg_cool"] .= 'La Afp fue adicionado satisfactoriamente!!.<br />';
			echo "<script> window.location.href='listAfp.php?show_msg=3'</script>";
				
		}
		else{
			$msg_info = true;
			$_SESSION["msg_cool"] .= 'No pudo ser adicionada la Afp!.<br />';
			echo "<script> window.location.href='listAfp.php?show_msg=1'</script>";
		}
	}
	
	if ( $msg_error )
		$show_msg = 1;
	elseif ( $msg_alert )
		$show_msg = 2;
	elseif ( $msg_info )
		$show_msg = 3;
?>